package com.paw.antd.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author lvzihai
 * @date 2021/8/14
 **/
@Data
@ApiModel(description = "result")
public class Result<T> {

  public static final int SUCCESS_CODE = 200;

  public static final int ERROR_CODE = 500;

  public static final String SUCCESS_MESSAGE="success";

  public static final String ERROR_MESSAGE="error";

  @ApiModelProperty("编码")
  private int code;

  @ApiModelProperty("消息")
  private String message;

  @ApiModelProperty("数据")
  private T context;

  public Result () {
  }

  public Result (int code, String message) {
    this.code = code;
    this.message = message;
  }

  public Result (int code, String message, T context) {
    this.code = code;
    this.message = message;
    this.context = context;
  }

  public  static <T> Result<T> success(T context){
    return new Result<>(SUCCESS_CODE,SUCCESS_MESSAGE,context);
  }

  public  static <T> Result<T> error(String message){
    return new Result<>(SUCCESS_CODE,message);
  }


}
